<?php

namespace App;

use Encore\Admin\Traits\ModelTree;
use Illuminate\Database\Eloquent\Model;

class Cascades extends Model
{
    use ModelTree;

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->setTitleColumn('name');
    }

    public function grade(){
        return $this->hasMany($this,'parent_id')->where('type',2);
    }

    public function subject(){
        return $this->hasMany($this,'parent_id')->where('type',3);
    }

}
